<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Leave_management_model extends CI_Model
{
	
	public function __construct()
	{
		parent::__construct();
	}
	
	public function get_all_leave()
	{
$this->db->select('user_leave.*,users.username');
$this->db->from('user_leave');
$this->db->join('users', 'user_leave.user_id = users.id');
return $this->db->get()->result();	
	}
	
	public function get_leave_by_id($id)
	{
		$this->db->select('user_leave.*,users.username');
		$this->db->from('user_leave');
		$this->db->where('user_leave.id',$id);
		$this->db->join('users', 'user_leave.user_id = users.id');
		return $this->db->get()->result();
	
	}
	
	public function grant_leave($data,$check)
	{
		$query = $this->db->update('user_leave',$data,$check);
		if($query){
		return 'Leave has been approved';	
		}
		else { 
		return FALSE;
		}
	}
	
}
